<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>操作员管理</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<link href="${ctx}/css/IFS.css" rel="stylesheet" type="text/css" />
	<script src="${ctx}/js/boot.js" type="text/javascript"></script>
	<style type="text/css">
	html, body{
		margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
	}
	</style>
</head>
<body>   
	<div class="mini-toolbar" style="padding:2px;border-bottom:0;">    
		<label style="font-family:Verdana;">用户名: </label>
		<input id="userid" name="userid" class="mini-textbox"/>
		<label style="font-family:Verdana;">操作人姓名: </label>
		<input id="operatorName" name="operatorName" class="mini-textbox" />
		<a class="mini-button" iconCls="icon-search" plain="true" onclick="onSearch()">查询</a>
	</div>
	<div class="mini-toolbar" style="padding:2px;border-bottom:0;">    
		<a class="mini-button" iconCls="icon-add" onclick="add()">新增</a>
		<a class="mini-button" iconCls="icon-edit" onclick="edit()">修改</a>
		<a class="mini-button" iconCls="icon-remove" onclick="remove()">删除</a>
	</div>
    <!--撑满页面-->
    <div class="mini-fit" >
		<div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" 
            url="${ctx}/acct/service/AcOperatorService/inquiryAcOperatorList.do"  idField="operatorId" data="list" dataField="list" multiSelect="false"
            sizeList="[5,10,20,50]" pageSize="10" totalField="pager.recordCount" sortField="operatorId" sortOrder="desc">
            <div property="columns">
            	<div type="checkcolumn" ></div>
 				<div field="operatorId" headerAlign="center" allowSort="true">操作员id</div>
                <div field="userid" headerAlign="center" allowSort="true">用户名</div>  
                <div field="operatorName" headerAlign="center" renderer="onType" allowSort="true">操作员姓名</div>  
                <div field="phone" headerAlign="center" allowSort="true">手机</div>  
                <div field="status" headerAlign="center" renderer="onStatus" allowSort="true">状态</div>  
                <div field="lastlogin"  headerAlign="center" dateFormat="yyyy-MM-dd HH:mm:ss" allowSort="true">最后登陆日期</div>
                <div field="datCreate"  headerAlign="center" dateFormat="yyyy-MM-dd HH:mm:ss" allowSort="true">创建日期</div>
            </div>
        </div> 
    </div>
   
	<script type="text/javascript">
		mini.parse();
		var grid = mini.get("datagrid1");
		grid.load();
		var statusList = mini.decode($.ajax({url:"${ctx}/sys/service/SysDictService/getDict.do?dictCode=status&feature=ac_operator",async:false}).responseText);
		function onSearch() {
			var operator = {};
			var userid = mini.getbyName("userid").value;
			var operatorName = mini.getbyName("operatorName").value;
			grid.load({userid:userid,operatorName:operatorName});
		}
		// 状态render，转换数据字典
		function onStatus(e) {
            for (var i = 0, l = statusList.length; i < l; i++) {
                var g = statusList[i];
                if (g.dictItemCode == e.value) {
                	return g.dictItemName;
                }
            }
            return "";
        }
		// 编辑
		function edit(){
			var row = grid.getSelected();
			if(!row){
				// mini.alert("请选择一条记录");
				layer.alert("请选择一条记录");
				return;
			}
			mini.open({
                 url: "${ctx}/acct/service/AcOperatorService/goAcOperatorWindow.do",
                 title: "编辑操作员", width: 600, height: 400,
                 onload: function () {
                     var iframe = this.getIFrameEl();
                     var data = { action: "edit", operatorId: row.operatorId };
                     iframe.contentWindow.SetData(data);

                 },
                 ondestroy: function (action) {
                     grid.reload();
                 }
             });
		 }
		// 新增
		function add(){
			mini.open({
                url: "${ctx}/acct/service/AcOperatorService/goAcOperatorWindow.do",
                title: "新增操作员", width: 600, height: 400,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "add"};
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
		}
		// 删除
	    function remove() {
	    	var rows = grid.getSelecteds();
			if(rows.length == 0){
				mini.alert("请选择一条记录");
				return;
			}
			if (confirm("确定删除选中记录？")) {
                var ids = [];
                for (var i = 0, l = rows.length; i < l; i++) {
                    var r = rows[i];
                    ids.push(r.operatorId);
                }
                var id = ids.join(',');
                console.log('ddd');
                grid.loading("操作中，请稍后......");
                $.ajax({
                    url: "${ctx}/acct/service/AcOperatorService/deleteAcOperator.do",
                    type: 'post',
	            	data: {operatorIds : id},
	            	cache: false,
	            	dataType : "json",
	            	success : function(data) { 	
						var o = mini.decode(data);
			        	if(o.success == true){
			        		grid.reload();
			        	}else{
			        		mini.alert(o.message);
			        	}
					} 
                });
            }
         }

    </script>

</body>
</html>
